package main

import (
	"fmt"
	"server/base"
	"server/base/db"

	"github.com/golobby/orm"
)

type User struct {
	Id   int
	Name string
}

func (this User) ConfigureEntity(e *orm.EntityConfigurator) {
	e.Table("user").Connection("default")
}

func main() {
	d, err := db.Connect(&db.Config{
		Name:    "master",
		DSN:     "root:@tcp(localhost:3306)/goadm?charset=utf8mb4&autocommit=1&parseTime=true",
		MaxIdle: 500,
		MaxLife: 300,
	})
	base.Raise(err)
	err = orm.SetupConnections(orm.ConnectionConfig{
		DB: d.DB,
		//Entities: []orm.Entity{User{}},
	})
	base.Raise(err)
	u, err := orm.Find[User](1)
	base.Raise(err)
	fmt.Println("user:", u)
}
